<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/3/14
 * Time: 10:21
 */

namespace App\Http\Logics\Admin;

use App\SystemNotify;
use App\Http\Logics\BaseLogic;
class SystemNotifyLogic extends BaseLogic
{
    public static function getSystemNotifyList($data)
    {
        $query = SystemNotify::where(function ($query) use ($data){
            if (isset($data['status']) && $data['status'] !== ''){
                $query->where('status', $data['status']);
            }
        });
        $system_notify = $data['limit'] ? $query->paginate($data['limit']) : $query->get();
        if (empty($system_notify)){
            return self::response(self::CONTENT_IS_EMPTY);
        }
        return self::response(self::SUCCESS, $system_notify);
    }

    public static function createSystemNotify($data)
    {
        $system_notify = new SystemNotify();
        $system_notify->content = $data['content'];
        if (!$system_notify->save()){
            return self::response(self::OBJECT_SAVE_FAIL);
        }
        return self::response(self::SUCCESS, $system_notify);
    }
}